import { usePageHelper } from "@/hook";
import { api } from "@/utils/api-instance";
import Taro from "@tarojs/taro";
import RatingRow from "@/pages/rating/components/rating-row";
import "./rating-list.scss";

export default function RatingList() {
  const { dataList, reloadPageData } = usePageHelper(
    api.ratingForFrontController.query,
    api.ratingForAdminController,
    { query: {} },
    { enableShowLoad: false, enableLoad: false },
  );
  Taro.useLoad(async ({ id }) => {
    await reloadPageData({ query: { deliverId: id } });
  });
  return (
    <div className="rating-list">
      {dataList.map((item) => {
        return (
          <div key={item.id} className="rating-wrapper">
            <RatingRow rating={item}></RatingRow>
          </div>
        );
      })}
    </div>
  );
}
